﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cn.Edwon.Web.Session;

namespace Cn.Edwon.Web.Ac {
    public class UserPower2{
        public UserPower2() {
            this._DeptKey = null;
            this._DeptLevel = null;
            this._DeptName = null;
            this._IsSysop = false;
            //this._RoleKey = null;
            //this._RoleLevel = null;
            //this._RoleName = null;
        }

        private Boolean _IsSysop;
        public Boolean IsSysop {
            get {
                return _IsSysop;
            }
            set {
                _IsSysop = value;
            }
        }

        private IList<Role> _RoleList;
        public IList<Role> RoleList {
            set { _RoleList = value; }
            get { return _RoleList; }
        }

        public Boolean _IsManager {
            get {
                if (_RoleList == null) return false;
                else {
                    foreach (Role r in _RoleList) {
                        if (r.IsManager)
                            return true;
                    }
                    return false;
                }
            }
        }
        
        public Int32 MaxRoleLevel {
            get {
                if (_RoleList == null) return 0;
                else {
                    Int32 _l = 0;
                    foreach (Role r in _RoleList) {
                        if (r.RoleLevel > _l)
                            _l = r.RoleLevel;
                    }
                    return _l;
                }
            }
        }

        //private string _RoleKey;
        //public string RoleKey {
        //    get {
        //        return _RoleKey;
        //    }
        //    set {
        //        _RoleKey = value;
        //    }
        //}

        //private string _RoleName;
        //public string RoleName {
        //    get {
        //        return _RoleName;
        //    }
        //    set {
        //        _RoleName = value;
        //    }
        //}
        //private Int32? _RoleLevel;
        //public Int32? RoleLevel {
        //    get {
        //        return _RoleLevel;
        //    }
        //    set {
        //        _RoleLevel = value;
        //    }
        //}
        private string _DeptKey;
        public string DeptKey {
            get {
                return _DeptKey;
            }
            set {
                _DeptKey = value;
            }
        }
        private string _DeptName;
        public string DeptName {
            get {
                return _DeptName;
            }
            set {
                _DeptName = value;
            }
        }
        private Int32? _DeptLevel;
        public Int32? DeptLevel {
            get {
                return _DeptLevel;
            }
            set {
                _DeptLevel = value;
            }
        }
    }

}
